package ssq.gamest.game;

import org.junit.Test
import ssq.gamest.game.Guandan.patterns.单张
import ssq.gamest.game.Guandan.patterns.对子
import ssq.gamest.game.Guandan.patterns.三张
import ssq.gamest.game.Guandan.patterns.三带对
import ssq.gamest.game.Guandan.patterns.顺子
import ssq.gamest.game.Guandan.patterns.连对
import ssq.gamest.game.Guandan.patterns.三顺
import ssq.gamest.game.Guandan.patterns.同花顺
import ssq.gamest.game.Guandan.patterns.炸弹4
import ssq.gamest.game.Guandan.patterns.炸弹5
import ssq.gamest.game.Guandan.patterns.炸弹6
import ssq.gamest.game.Guandan.patterns.王炸

import ssq.gamest.game.Shengji.patterns.主点
import ssq.gamest.game.Shengji.patterns.主点对
import ssq.gamest.game.Shengji.patterns.副主点
import ssq.gamest.game.Shengji.patterns.副主点对
import ssq.gamest.game.Shengji.patterns.主
import ssq.gamest.game.Shengji.patterns.主对
import ssq.gamest.game.Shengji.patterns.主拖拉机
import ssq.gamest.game.Shengji.patterns.副
import ssq.gamest.game.Shengji.patterns.副对
import ssq.gamest.game.Shengji.patterns.副拖拉机

import ssq.gamest.game.TexasPoker.patterns.同花

public class PokerCardGroupTest
{

	/**
     * 掼蛋, 打10
     */
	@Test
	def void testGuandan()
	{
		var poker = new Poker("掼蛋", "Guandan");

		var settings = new PokerOrderSettings(#[2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 1, 10, 14, 15], #[Color.diamonds, Color.clubs, Color.hearts, Color.spades, Color.none], false, poker);
		settings.setTwoEndian(#[1]);

		//        var object = JSONObject.fromObject("[[\"`others`\", \"炸弹4\", \"炸弹5\", \"同花顺\", \"炸弹6\", \"王炸\"]]");
		settings.setPatternAndOrder(#[#["`others`", "炸弹4", "炸弹5", "同花顺", "炸弹6", "王炸"], #["对子"]])

		poker.settings = settings

		var tmpGroup = new PokerCardGroup(
			poker,
//			new PokerCard(2, Color.spades, poker),
//			new PokerCard(2, Color.spades, poker),
			//                new PokerCard(3, Color.spades, poker),
			//                new PokerCard(3, Color.spades, poker),
			//                new PokerCard(3, Color.diamonds, poker),
			//                new PokerCard(3, Color.diamonds, poker),
			//                new PokerCard(3, Color.diamonds, poker),
//			new PokerCard(3, Color.diamonds, poker),
//			new PokerCard(3, Color.diamonds, poker),
//			new PokerCard(3, Color.hearts, poker),
			//
			                new PokerCard(6, Color.diamonds, poker),
			                new PokerCard(7, Color.diamonds, poker),
			                new PokerCard(8, Color.diamonds, poker),
			                new PokerCard(9, Color.diamonds, poker),
			                new PokerCard(11, Color.diamonds, poker)
			//                new PokerCard(14, Color.none, poker),
			//                new PokerCard(15, Color.none, poker),
			//                new PokerCard(15, Color.none, poker),
			//                new PokerCard(15, Color.none, poker),
//			new PokerCard(2, Color.spades, poker)
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(14, Color.none, poker),
		//                new PokerCard(14, Color.none, poker)
		)

		println(new 单张().match(tmpGroup).size)
		println(new 对子().match(tmpGroup).size)
		println(new 三张().match(tmpGroup).size)
		println(new 三带对().match(tmpGroup).size)
		println(new 顺子().match(tmpGroup).size)
		println(new 连对().match(tmpGroup).size)
		println(new 三顺().match(tmpGroup).size)
		println(new 同花顺().match(tmpGroup).size)
		println(new 炸弹4().match(tmpGroup).size)
		println(new 炸弹5().match(tmpGroup).size)
		println(new 炸弹6().match(tmpGroup).size)
		println(new 王炸().match(tmpGroup).size)
	}

	/**
     * 升级, 打10, 黑桃
     */
	@Test
	def void testTexasPoker()
	{
		var poker = new Poker("德州扑克", "TexasPoker");

		var settings = new PokerOrderSettings(#[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 14, 15], #[Color.diamonds, Color.clubs, Color.hearts, Color.spades, Color.none], true, poker);

		settings.setPatternAndOrder(#[#["高牌", "对子", "两对", "三条", "顺子", "同花", "葫芦", "四条", "同花顺"]])
		settings.setTwoEndian = #[1]
		poker.settings = settings

		var tmpGroup = new PokerCardGroup(
			poker,
//			new PokerCard(10, Color.diamonds, poker),
//			new PokerCard(10, Color.diamonds, poker)
//			new PokerCard(12, Color.diamonds, poker),
			new PokerCard(12, Color.diamonds, poker),
			new PokerCard(11, Color.diamonds, poker),
			new PokerCard(11, Color.diamonds, poker),
			new PokerCard(10, Color.diamonds, poker),
			new PokerCard(10, Color.diamonds, poker)
		//			new PokerCard(11, Color.spades, poker),
		//			new PokerCard(10, Color.diamonds, poker)
//		                new PokerCard(3, Color.spades, poker),
//		                new PokerCard(3, Color.spades, poker)
		//                new PokerCard(3, Color.diamonds, poker),
		//                new PokerCard(3, Color.diamonds, poker),
		//                new PokerCard(3, Color.diamonds, poker),
		//			new PokerCard(3, Color.diamonds, poker),
		//			new PokerCard(3, Color.diamonds, poker),
		//			new PokerCard(3, Color.hearts, poker),
		//
		//                new PokerCard(6, Color.diamonds, poker),
		//                new PokerCard(7, Color.diamonds, poker),
		//                new PokerCard(8, Color.diamonds, poker),
		//                new PokerCard(9, Color.diamonds, poker),
		//                new PokerCard(11, Color.diamonds, poker)
		//                new PokerCard(14, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//			new PokerCard(2, Color.spades, poker)
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(14, Color.none, poker),
		//                new PokerCard(14, Color.none, poker)
		)
		println(new 同花().match(tmpGroup).size)
	}
	
	/**
     * 升级, 打10, 黑桃
     */
	@Test
	def void testShengji()
	{
		var poker = new Poker("升级", "Shengji");

		var settings = new PokerOrderSettings(#[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 14, 15], #[Color.diamonds, Color.clubs, Color.hearts, Color.spades, Color.none], true, poker);

		//        var object = JSONObject.fromObject("[[\"`others`\", \"炸弹4\", \"炸弹5\", \"同花顺\", \"炸弹6\", \"王炸\"]]");
		settings.someColors = #[Color.spades]
		settings.somePoints = #[10]
		settings.setPatternAndOrder(#[#["副", "主", "副主点", "主点"], #["副对", "主对", "副主点对", "主点对"], #["副拖拉机", "主拖拉机"]])
//		settings.setTwoEndian = #[1]
		poker.settings = settings

		var tmpGroup = new PokerCardGroup(
			poker,
			new PokerCard(10, Color.diamonds, poker),
			new PokerCard(10, Color.diamonds, poker),
			new PokerCard(12, Color.diamonds, poker),
			new PokerCard(12, Color.diamonds, poker),
			new PokerCard(11, Color.diamonds, poker),
			new PokerCard(11, Color.diamonds, poker)
//			new PokerCard(10, Color.spades, poker),
//			new PokerCard(10, Color.spades, poker)
		//			new PokerCard(11, Color.spades, poker),
		//			new PokerCard(10, Color.diamonds, poker)
//		                new PokerCard(3, Color.spades, poker),
//		                new PokerCard(3, Color.spades, poker)
		//                new PokerCard(3, Color.diamonds, poker),
		//                new PokerCard(3, Color.diamonds, poker),
		//                new PokerCard(3, Color.diamonds, poker),
		//			new PokerCard(3, Color.diamonds, poker),
		//			new PokerCard(3, Color.diamonds, poker),
		//			new PokerCard(3, Color.hearts, poker),
		//
		//                new PokerCard(6, Color.diamonds, poker),
		//                new PokerCard(7, Color.diamonds, poker),
		//                new PokerCard(8, Color.diamonds, poker),
		//                new PokerCard(9, Color.diamonds, poker),
		//                new PokerCard(11, Color.diamonds, poker)
		//                new PokerCard(14, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//			new PokerCard(2, Color.spades, poker)
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(15, Color.none, poker),
		//                new PokerCard(14, Color.none, poker),
		//                new PokerCard(14, Color.none, poker)
		);
		println(new 主点().match(tmpGroup).size)
		println(new 主点对().match(tmpGroup).size)
		println(new 副主点().match(tmpGroup).size)
		println(new 副主点对().match(tmpGroup).size)
		println(new 主().match(tmpGroup).size)
		println(new 主对().match(tmpGroup).size)
		println(new 主拖拉机().match(tmpGroup).size)
		println(new 副().match(tmpGroup).size)
		println(new 副对().match(tmpGroup).size)
		println(new 副拖拉机().match(tmpGroup).size)
	}
}
